# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gst-plugins-base

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.3.1
pkgrel=1
pkgdesc="GStreamer Multimedia Framework Base Plugins (mingw-w64)"
arch=('any')
url="http://gstreamer.freedesktop.org/"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
            "${MINGW_PACKAGE_PREFIX}-pkg-config"
            "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
            )
depends=("${MINGW_PACKAGE_PREFIX}-libvorbis"
        "${MINGW_PACKAGE_PREFIX}-libtheora"
        "${MINGW_PACKAGE_PREFIX}-pango"
        #"${MINGW_PACKAGE_PREFIX}-libvisual"
        #"${MINGW_PACKAGE_PREFIX}-cdparanoia"
        "${MINGW_PACKAGE_PREFIX}-gstreamer"
        "${MINGW_PACKAGE_PREFIX}-orc"
        )
options=(!libtool strip staticlibs)
source=(${url}/src/${_realname}/${_realname}-${pkgver}.tar.xz
        0002-fix-test-running.mingw.patch
        0003-fix-riff-includes.mingw.patch
        0004-fix-X-detection.mingw.patch
        0006-disable-sse-detection.mingw.patch
        0007-link-to-ws2.all.patch
        0008-fix-w32-examples.all.patch
        0009-fix-casting-error.patch
        give-cc-to-gir-scanner.mingw.patch)
md5sums=('40eb46219b64dc1998c1a005195c0b6c'
         '006091acfeedd194fa804ea36958ea3c'
         '571194f25c8c765b5b5e5739df1271ae'
         'e4d0591f928ce2034ecfe859f4938587'
         'ee35e5a95bdcb9e7f7f5a8848dd6dc4c'
         '745cfb58b510b98c38400e9e263d442c'
         'c8405c21a780105e908ed340453b7cc0'
         '59679a91af5eea1f303c6ee59441b04a'
         '4d45f704f60a5c63b6c4c7d448d2b152')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0002-fix-test-running.mingw.patch
  patch -p1 -i ${srcdir}/0003-fix-riff-includes.mingw.patch
  patch -p1 -i ${srcdir}/0004-fix-X-detection.mingw.patch
  patch -p1 -i ${srcdir}/0006-disable-sse-detection.mingw.patch
  patch -p1 -i ${srcdir}/0007-link-to-ws2.all.patch
  patch -p1 -i ${srcdir}/0008-fix-w32-examples.all.patch
  patch -p1 -i ${srcdir}/0009-fix-casting-error.patch
  patch -p1 -i ${srcdir}/give-cc-to-gir-scanner.mingw.patch

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  cp -r "${srcdir}/${_realname}-${pkgver}" "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --disable-static \
    --enable-shared \
    --enable-silent-rules \
    --enable-experimental \
    --disable-gtk-doc
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make -j1 DESTDIR="$pkgdir" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
  rm -f ${pkgdir}${MINGW_PREFIX}/lib/gstreamer*/*.a
}
